// 数据操作视图
import router from '@/router'
import {
    Message,
    MessageBox
} from 'element-ui'
import request from '@/util/request'
/**
    列表表格头部 搜索条件
    type =0 为输入框  1为下拉框 2为 起止时间选择
    url 下拉框请求数据的接口地址
**/
const searchView = [
    {
        label: '发货单号',
        prop: 'code',
        type: 0
    },
    {
        label: '客户订单号',
        prop: 'ownerOrderCode',
        type: 0
    },
    {
        label: '状态',
        prop: 'status',
        type: 1,
        url: '/omsService/oms/commom/data/status'
    },
    {
        label: '货主',
        prop: 'ownerCode',
        type: 1,
        url: '/omsService/oms/commom/data/status'
    },
    {
        label: '订单类型',
        prop: 'deliveryOrderType',
        type: 1,
        url: '/omsService/oms/commom/data/orderType'
    },
    {
        label: '发货方',
        prop: 'sender',
        type: 1,
        url: '/oms/commom/data/ownerAddress',
        parameter: {
            ownerCode: 'ownerCode'
        },
    },
    {
        label: '收货方',
        prop: 'receiver',
        type: 1,
        url: '/omsService/oms/commom/data/ownerAddress',
        parameter: {
            ownerCode: 'ownerCode'
        }
    },
    {
        label: '运输方式',
        prop: 'transportMethod',
        type: 1,
        url: '/omsService/oms/commom/data/transportMethod'
    },
    {
        label: '下单时间',
        prop: 'orderTimeBegin,orderTimeEnd',
        type: 2
    }
]
/**
    表格数据
**/
const TableView = {
    url: '/oms/order/deliveryOrder/pageInfo', //表格请求的url
    IsCheck: true, // 表格是否显示勾选框
    IsSerialNumber: true, // 是否显示序号
    addBtn: { // 新增按钮 为空则不显示此按钮
        name: '新增',
        callBack() { // 新增加按钮回调方法
            router.push({
                path: 'addDeliveryOrder'
            })
        }
    },
    fieldList: [
        {
            label: '发货单号',
            prop: 'code',
            width: 150
        }, {
            label: '客户订单号',
            prop: 'ownerOrderCode',
            width: 120
        }, {
            label: '状态',
            prop: 'statusName',
            width: 0
        }, {
            label: '货主',
            prop: 'ownerName',
            width: 180
        }, {
            label: '订单类型',
            prop: 'deliveryOrderTypeName',
            width: 0
        }, {
            label: '运输方式',
            prop: 'transportMethod',
            width: 0
        }, {
            label: '下单时间',
            prop: 'createTime',
            width: 140
        }, {
            label: '计划发货日期',
            prop: 'orderTime',
            width: 140
        }, {
            label: '计划收货日期',
            prop: 'updateTime',
            width: 140
        }, {
            label: '发货方',
            prop: 'sender',
            width: 0
        }, {
            label: '收货方',
            prop: 'receiver',
            width: 0
        }, {
            label: '订单来源',
            prop: '',
            width: 0
        }
    ],
    btList: [
        {
            label: '编辑',
            type: 'success',
            callBack(res) { // 回调方法
                router.push({
                    path: 'addDeliveryOrder'
                })
            }
        },
        {
            label: '执行',
            type: 'danger',
            callBack(res) {
                MessageBox.confirm('确认执行选中的记录么？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(async () => {
                    let ress = await request.zhycpost('/omsService/oms/order/deliveryOrder/execute/' + res.id)
                    Message({
                        message: ress.msg,
                        type: 'error',
                        duration: 5 * 1000
                    })
                }).catch(() => {

                });
            }
        },
        {
            label: '取消',
            type: 'danger',
            callBack(res) {
                MessageBox.confirm('确认执行选中的记录么？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(async () => {
                    let ress = await request.zhycpost('/oms/order/deliveryOrder/cancel/' + res.id)
                    Message({
                        message: ress.msg,
                        type: 'error',
                        duration: 5 * 1000
                    })
                }).catch(() => {

                });
            }
        }
    ]
}
export {
    TableView,
    searchView
}
